package com.example.tests;

import java.util.Collections;
import java.util.List;
import static org.testng.Assert.assertEquals;
import org.testng.annotations.Test;
//import org.junit.*;


public class GroupCreationTests extends TestBase{
	
	
	
	@Test(dataProvider = "randomValidGroupGenerator")
	public void testGroupCreationWithValidData(GroupData group) throws Exception {
		app.getNavigationHelper().openMainPage();
		app.getNavigationHelper().goToGroupPage();
		//save old state
		List<GroupData> oldList = app.getGroupHelper().getGroups();
		
		app.getGroupHelper().initGroupCreation();
		app.getGroupHelper().fillInfoForNewGroup(group);
		app.getGroupHelper().submitCreationOfNewGroup();
		app.getNavigationHelper().returnToGroupPage();
		
		List<GroupData> newList = app.getGroupHelper().getGroups();		
		oldList.add(group);
	    Collections.sort(oldList);
		assertEquals(newList, oldList);
		
	}
	
      @Test
	public void testEmptyGroupCreation() throws Exception {
		app.getNavigationHelper().openMainPage();
		app.getNavigationHelper().goToGroupPage();
		List<GroupData> oldList = app.getGroupHelper().getGroups();
		
		app.getGroupHelper().initGroupCreation();
		GroupData group = new GroupData("","","");
		app.getGroupHelper().fillInfoForNewGroup(group);
		app.getGroupHelper().submitCreationOfNewGroup();
		app.getNavigationHelper().returnToGroupPage();
		List<GroupData> newList = app.getGroupHelper().getGroups();		
		oldList.add(group);
	    Collections.sort(oldList);
		assertEquals(newList, oldList);
	}
}
